const app = getApp(),
      api = require("../../../utils/api.js"),
      request = require("../../../service/request.js");
var	  page = 0;


Page({
	data: {  
	    /*页面配置 */  
	    winWidth: 0,  
	    winHeight: 0,  
	    //面经数据
	    MJList:{},
  	}, 
	onLoad:function(options){
		var that = this;
		request.get(`${api.getSharedList}?page=${page}`, {}, app.globalData.sessionid).then(res => {
			console.log(res.data);
	        that.setData({
	          MJList:res.data
	        })
		})

	    wx.getSystemInfo({
	      success: function (res) {
	        var clientHeight = res.windowHeight-120,
	        clientWidth = res.windowWidth,
	        rpxR = 750 / clientWidth;
	        var calc = clientHeight * rpxR;
	        //console.log(calc)
	        that.setData({
	          winHeight: calc
	        });
	      }
	    });

	},


	pullUpLoad: function() {
    	var that = this; 
		page++;
		request.get(`${api.getSharedList}?page=${page}`, {}, app.globalData.sessionid).then(res => {
			console.log(res.data.length);
			var isBottom = (!res.data.length==0)?true:false;
			if(isBottom){
			wx.showLoading({
			  title: '加载更多数据',
			  icon: 'loading',
			  duration:2000
			})
			var moment_list = that.data.MJList;
			for (var i = 0; i < res.data.length; i++) {
			  moment_list.push(res.data[i]);
			}

			that.setData({
			  MJList:moment_list
			})
			wx.hideLoading();
			console.log("面经加载page="+page);
			console.log(res.data);
			} else {
			wx.showToast({
			  title: '亲，到底啦！',
			  icon: 'none',
			  duration:1000
			})
			page--;
			console.log("面经加载page="+page);
			}
		})
    }
	

})		